def set_attachment(self, filename):
    print("going to attach file")
    with open(filename, 'rb') as f:
        attachment = MIMEText(f.read(), 'base64', 'utf-8')
        attachment.add_header('Content-Disposition', 'attachment', filename=filename)
        self.content.attach(attachment)
    print("attach function completed")
MIMEText